﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
public partial class administrator_uc_admin_r_order : UserControl
{
    public static DataTable dt = null;
    public static string sortexpression = string.Empty;
    public static string sortdirection = string.Empty;    

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {                     
            DataTable dtOrderStatus = new CmsBLL().GetOrderStatus();


            lt_customer.Text = ViewDataGrid();

            drd_OrderStatus.DataSource = dtOrderStatus;
            drd_OrderStatus.DataValueField = "StatusID";
            drd_OrderStatus.DataTextField = "StatusName";
            drd_OrderStatus.DataBind();

        }
        drd_OrderStatus.AutoPostBack = true;
        drd_OrderStatus.SelectedIndexChanged += new EventHandler(drd_OrderStatus_SelectedIndexChanged);
    }

    void drd_OrderStatus_SelectedIndexChanged(object sender, EventArgs e)
    {     
    }

    string ViewDataGridByOrderStatus(int statusId)
    {
        dt = new DataTable();
        dt = new CmsBLL().Report_CartOrderGetList(statusId, txtFromDate.Text.Trim(), txtToDate.Text.Trim());
        return new CmsBLL().Reports_OrderRender(dt);
    }

    string ViewDataGrid()
    {

        //dt = new CmsBLL().CartOrder_GetList(sortexpression, sortdirection);
        dt = new CmsBLL().CartOrder_Search(txtFromDate.Text.Trim(), txtToDate.Text.Trim());
        return new CmsBLL().Reports_OrderRender(dt);
    }
    protected void btn_View_Click(object sender, EventArgs e)
    {
        //dt = new BLL.CmsBLL().CartOrder_Search(txtKeyWord.Text + "", txtFromDate.Text.Trim(), txtToDate.Text.Trim());
        int orderStatusId = int.Parse(drd_OrderStatus.SelectedItem.Value);
        if (orderStatusId == 0)
        {
            lt_customer.Text = ViewDataGrid();
        }
        else
        {
            lt_customer.Text = ViewDataGridByOrderStatus(orderStatusId);
        }
    }
}